﻿@using Project_2._2.Models;
@model IEnumerable<Project_2._2.Models.Xe>
@{
    ViewBag.Title = "SearchNomarl";
    Layout = "~/Views/Shared/_UserLayoutPage2.cshtml";
    Project_2._2.Models.QuanLyThueXeEntities db = new Project_2._2.Models.QuanLyThueXeEntities();
}

@* ToolTip *@
<script type="text/javascript">

    function dotooltip(hinh) {
        document.getElementById("hinh").src = hinh;
        document.getElementById("ToolTip").style.visibility = "visible";
    };
    document.onmousemove = function (e) {
        if (e == null)//neu la IE hoac chrome
        {
            mx = event.pageX;
            my = event.pageY;
        }
        else // firefox hoac operrator
        {
            mx = e.clientX;
            my = e.clientY;
        }
        div_tt = document.getElementById("ToolTip").style;
        if (mx > 880)
        { div_tt.left = (mx - 460) + "px"; }
        else
        { div_tt.left = (mx + 10) + "px"; }
        if(my > 300)
            div_tt.top = (my - 300) + "px";
        else
            div_tt.top = (my - 100) + "px";
    }
    function hide() {
        document.getElementById("ToolTip").style.visibility = "hidden";
    };
</script>
<!-- ToolTip san pham --->
<div id="ToolTip" style="width:auto ; height:auto; border:2px solid red; position:fixed; z-index:999; border-radius:10px; visibility:hidden">
    <img id="hinh" width="450" />
</div>
@*  end ToolTip   *@

@*   Accordion tab JqueryUI *@
<link href="~/Content/Jquery%20Css/jquery-ui.css" rel="stylesheet" />
<script src="~/Script/Jquery%20Js/jquery-ui.js"></script>
<script>
    $(function () {
        $("#accordion").accordion({
            heightStyle: "content"
        });

     });
</script>

<div style="width:748px; height:auto; border:2px solid #cfcfcf; border-radius:5px; margin-top:10px">
    <div style="height:54px; width:748px; background:url('../Images/UserDesign/bg_right.png') repeat-x; border-bottom:2px solid #cfcfcf;">
        <div style="width:105px; height:54px; float:left; margin-left:5px;">
            <img src="../Images/UserDesign/car.png" />
        </div>
        <div style="width:638px; height:54px; float:right">
            <span style="font-weight:bold; color:#ffffff; font-family:Tahoma; font-size:14px; line-height:38px">KẾT QUẢ TÌM KIẾM</span>
        </div>
    </div>

    <div style="height:auto; width:748px">
        @foreach (var car in Model)
        {
            <div class="sp">
                <div class="sp_name">@car.TenXe</div>
                    <div>
                        <div>
                            <img src="~/Images/Cars/@car.HinhAnhXes" style="cursor:pointer" width="160" height="110" onmouseover="dotooltip('../Images/Cars/@car.HinhAnhXes')" onmouseout="hide()" />
                        </div>
                        <div class="sp_detail">
                            
                            @{                              
                                var giaxedv = from gia in db.GiaXes select gia;
                                var thieu = from thuonghieu in db.ThuongHieux select thuonghieu ;
                                var loai = from loaixe in db.LoaiXes select loaixe;
                                //var dichvu = from dichvu in db.DichVuThueXes select dichvu;
                                
                                string TenHieu = null;
                                string Loaixe = null;
                                decimal giaxe = 0 ;
                                string dv = null ;

                                foreach (var itemgia in giaxedv)
                                {
                                    if (itemgia.XeId == car.XeId) 
                                    {
                                        giaxe = itemgia.Gia;
                                    }
                                }

                                foreach (var itemthuonghieu in thieu)
                                {
                                    if (itemthuonghieu.ThuongHieuId == car.ThuongHieuId)
                                    {
                                        TenHieu = itemthuonghieu.TenThuongHieu;
                                    }
                                }

                                foreach (var itemloai in loai)
                                {
                                    if (itemloai.LoaiXeId == car.LoaiXeId)
                                    {
                                        Loaixe = itemloai.TenLoaiXe;
                                    }
                                }

                                //foreach (var itemdv in dichvu)
                                //{
                                //    if (itemdv.DichVuId == )
                                //    {
                                //        Loaixe = itemloai.TenLoaiXe;
                                //    }
                                //}
                                 //var listhieuxe = (from p in db.ThuongHieux where p.ThuongHieuId == @car.ThuongHieuId select p).FirstOrDefault();
                                 //var listDichVu = (from p in db.DichVuThueXes where p.DichVuId == @car.di select p).FirstOrDefault();
                                 //var listKieuXe = (from p in db.LoaiXes where p.LoaiXeId == @car.LoaiXeId select p).FirstOrDefault();
                                 //var Listgia = (from p in db.GiaXes where p.XeId == @car.XeId select p).FirstOrDefault();
                                 
                            }
                            Hiệu : @TenHieu <br />
                            Dòng xe: Civic<br />
                            Đời xe : @car.DoiXe <br />
                            Kiểu xe : @Loaixe<br />
                            Màu xe : @car.MauXe<br />
                            Giá thuê tháng :<span> @string.Format("{0:#,### đ}",@giaxe)</span><br />
                        </div>
                        <div style="clear:right"></div>
                        <div style="text-align:center; margin-bottom:10px">
                            <input type="button" value="Đặt Xe" class="Button" style=" margin-top:5px" />
                            <a href="@Url.Action("ChiTiet", "Xe", new {  id = car.XeId})" style="font-size:13px; text-decoration:none; padding-top:5px" class="Button">Xem Chi tiết</a>
                    </div>
                </div>
            </div>
        }
        
    </div>
</div>




